package com.hyd.manage.service.impl;

import java.util.Collections;
import java.util.List;
import com.hyd.common.utils.DateUtils;
import com.hyd.manage.domain.Sales;
import com.hyd.manage.mapper.SalesMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hyd.manage.mapper.SalesRecordMapper;
import com.hyd.manage.domain.SalesRecord;
import com.hyd.manage.service.ISalesRecordService;

/**
 * 药品销售记录Service业务层处理
 * 
 * @author hwb
 * @date 2025-02-20
 */
@Service
public class SalesRecordServiceImpl implements ISalesRecordService 
{
    @Autowired
    private SalesRecordMapper salesRecordMapper;
    @Autowired
    private SalesMapper salesMapper;

    /**
     * 查询药品销售记录
     * 
     * @param id 药品销售记录主键
     * @return 药品销售记录
     */
    @Override
    public SalesRecord selectSalesRecordById(Long id)
    {
        return salesMapper.selectSalesById(id);
    }

    /**
     * 查询药品销售记录列表
     * 
     * @param salesRecord 药品销售记录
     * @return 药品销售记录
     */
    @Override
    public List<SalesRecord> selectSalesRecordList(SalesRecord salesRecord)
    {
        return salesMapper.selectSalesAll(salesRecord);
    }

    /**
     * 查询药品销售记录为1的列表
     *
     * @param salesRecord 药品销售记录
     * @return 药品销售记录
     */
    @Override
    public List<SalesRecord> selectSalesRecordListByStatus(SalesRecord salesRecord) {
        return salesMapper.selectSalesAllByStatus(salesRecord);
    }

    /**
     * 新增药品销售记录
     * 
     * @param salesRecord 药品销售记录
     * @return 结果
     */
    @Override
    public int insertSalesRecord(SalesRecord salesRecord)
    {
        salesRecord.setCreateTime(DateUtils.getNowDate());
        return salesRecordMapper.insertSalesRecord(salesRecord);
    }

    /**
     * 修改药品销售记录
     * 
     * @param sales 药品销售记录
     * @return 结果
     */
    @Override
    public int updateSalesRecord(Sales sales)
    {
        sales.setUpdateTime(DateUtils.getNowDate());
        return salesMapper.updateSales(sales);
    }

    /**
     * 批量删除药品销售记录
     * 
     * @param ids 需要删除的药品销售记录主键
     * @return 结果
     */
    @Override
    public int deleteSalesRecordByIds(Long[] ids)
    {
        return salesMapper.deleteSalesByIds(ids);
    }

    /**
     * 删除药品销售记录信息
     * 
     * @param id 药品销售记录主键
     * @return 结果
     */
    @Override
    public int deleteSalesRecordById(Long id)
    {
        return salesRecordMapper.deleteSalesRecordById(id);
    }
}
